cmake_minimum_required(VERSION 3.4.1)

# 设置输出so目标目录
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/libs/${ANDROID_ABI})

# 设置库名及打包的cpp
file(GLOB source_files "src/main/cpp/*.cpp")
add_library(native-lib
            SHARED
            ${source_files})

# 设置头文件目录
include_directories(src/main/cpp/include
                    src/main/cpp/include/jsoncpp
                    src/main/cpp/include/curl
                    )

# 添加引用库所在逻辑, STATIC:代表.a库， SHARED:代表.so库
add_library(curl STATIC IMPORTED)
set_target_properties(curl
                      PROPERTIES IMPORTED_LOCATION
                      ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libcurl.a)

add_library(jsoncpp STATIC IMPORTED)
set_target_properties(jsoncpp
                      PROPERTIES IMPORTED_LOCATION
                      ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libjsoncpp.a)

# 查找ndk需要的库文件
find_library( log-lib
              log )

# 目标文件与库文件链接
target_link_libraries( # Specifies the target library. 需要链接库
                       native-lib

                       # Links the target library to the log library
                       # included in the NDK. 引入文件
                       jsoncpp
                       curl
                       ${log-lib} )

